package manage.action;

import m.common.action.ActionMeta;
import m.common.action.VuePageResult;
import m.common.action.VueResult;
import m.system.util.JSONMessage;
import manage.model.ServerSetting;
import manage.service.ServerSettingService;

@ActionMeta(name="manage/serverSetting")
public class ServerSettingAction extends ManageAction {

	private ServerSetting model;
	
	public JSONMessage doSave(){
		JSONMessage result=new JSONMessage();
		try {
			verifyAdminOperPower("manage_system_power");
			String msg=getService(ServerSettingService.class).save(model);
			fillJSONResult(result,true,msg);
		} catch (Exception e) {
			fillJSONResult(result,false,e);
		}
		return result;
	}
	public JSONMessage doDeleteAll(){
		JSONMessage result=new JSONMessage();
		try {
			verifyAdminOperPower("manage_system_power");
			getService(ServerSettingService.class).deleteAllRecord();
			fillJSONResult(result,true,"删除成功");
		} catch (Exception e) {
			fillJSONResult(result,false,e);
		}
		return result;
	}

	public VueResult toEdit() throws Exception {
		return new VuePageResult("page/base/host/serverSetting.js")
			.addParam("model",getService(ServerSettingService.class).getUniqueModel());
	}

	public ServerSetting getModel() {
		return model;
	}

	public void setModel(ServerSetting model) {
		this.model = model;
	}
}
